/**
 * 				serverRMI.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	serverClasses
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.serverClasses;

import java.io.FileNotFoundException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Set;

import mochito.dataClasses.DataManager;
import mochito.dataClasses.musicItem.MusicItem;

/**
 * @author  bin04017
 */
public class ServerRMI extends UnicastRemoteObject implements ServerInterface {

	/**
	 * 
	 */
	private static final long serialVersionUID = -9106573277277742815L;
	private DataManager manager = new DataManager();
	/**
	 * @throws RemoteException
	 */
	public ServerRMI() throws RemoteException {
		super();
	}

	public byte[] retrieveFile(String name) throws RemoteException, FileNotFoundException {
		return manager.getMusicItem(name).retrieveFile();
	}

	public String getMusicItemStartTime(String name) throws RemoteException {
		MusicItem item = manager.getMusicItem(name);
		return item.getStartTime();
	}
	public String getMusicItemStartDate(String name) throws RemoteException {
		MusicItem item = manager.getMusicItem(name);
		return item.getStartDate();
	}
	public void addMusicItem(MusicItem item) throws RemoteException {
		manager.addMusicItem(item);		
	}

	public Set<String> getMusicItems() throws RemoteException {
		return manager.getMusicItems();
	}
	public void removeMusicItem(MusicItem item) throws RemoteException {
		manager.removeMusicItem(item);
	}

	public String getMusicItemFile(String item) throws RemoteException {
		return manager.getMusicItem(item).getFile().getAbsolutePath();
	}


}
